﻿using System;
using System.Windows;
using LayeredArchitectureSample.ViewModel;

namespace LayeredArchitectureSample.ClientBrowser
{
    public partial class NewLocationView : Window
    {
        private readonly NewLocationViewModel _newWareWindowViewModel;

        internal NewLocationView(NewLocationViewModel newWareWindowViewModel)
        {
            if (newWareWindowViewModel == null) throw new ArgumentNullException("newWareWindowViewModel");

            InitializeComponent();

            _newWareWindowViewModel = newWareWindowViewModel;

            this.DataContext = newWareWindowViewModel;
        }

        private void AddLocationButtonClick(object sender, RoutedEventArgs e)
        {
            _newWareWindowViewModel.AddNewLocationToRepository();

            // TODO: closing away is not good!
            this.Close();
        }

        private void CancelButtonClick(object sender, RoutedEventArgs e)
        {
            this.Close();
        }
    }
}